const path = require('path');
const express = require('express')
const app = express();

const apiRoutes = express.Router();
app.use('/api', apiRoutes);
// console.log(__dirname)
function resolve (dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    baseUrl: "./",
    // 输出目录
    outputDir: 'zht',
    lintOnSave: true,
    // 是否为生产环境构建生成 source map？
    productionSourceMap: false,
    // alias 配置
    chainWebpack: (config) => {
        config.resolve.alias
            .set('@', resolve('src'))
        // config.module.rules.delete("svg");
        config.module
            .rule('svg-smart')
            .test(/\.svg$/)
            .include
            .add(resolve('src/icons'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({
                symbolId: 'icon-[name]'
            })
    },

    devServer: {
        // host: '0.0.0.0',
        proxy: {
            '/api': {
                target: `${process.env.VUE_APP_URL}`,
                // target: 'https://cc.ctbls.com/',
                changeOrigin: true,
                ws: true,
                pathRewrite: {
                    '^/api': ''
                }
            }
        }
    }
}
